# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=exitmap
pkgver=373.8155029
pkgrel=3
groups=('blackarch' 'blackarch-recon')
arch=('any')
pkgdesc='A fast and modular scanner for Tor exit relays.'
url='https://github.com/NullHypothesis/exitmap'
license=('GPL3')
depends=('python2' 'python2-dnspython' 'python2-stem' 'python2-configparser'
         'python2-pysocks' 'tor')
makedepends=('git')
source=("git+https://github.com/NullHypothesis/$pkgname.git")
sha512sums=('SKIP')

pkgver() {
  cd $pkgname

  echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}

package() {
  cd $pkgname

  install -dm 755 "$pkgdir/usr/bin"
  install -dm 755 "$pkgdir/usr/share/$pkgname"

  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname" README.md doc/*
  install -Dm 644 COPYING "$pkgdir/usr/share/licenses/$pkgname/COPYING"

  rm -rf README.md doc

  cp -a --no-preserve=ownership * "$pkgdir/usr/share/$pkgname/"

  cat > "$pkgdir/usr/bin/$pkgname" << EOF
#!/bin/sh
cd /usr/share/$pkgname/bin
exec python2 $pkgname "\$@"
EOF

  chmod +x "$pkgdir/usr/bin/$pkgname"
}

